package com.gxa.modules.sys.controller;

import com.gxa.common.utils.Result;
import com.gxa.modules.sys.entity.Duration;
import com.gxa.modules.sys.mapper.DurationMapper;
import com.gxa.modules.sys.service.DurationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "时长兑换接口")
@RestController
public class DurationController {

    @Autowired
    private DurationService durationService;
    @ApiOperation(value = "时长查询接口")
    @GetMapping("/duration/query")
    public Result queryAll(){
        try {
            List<Duration> durations = this.durationService.queryAll();
            return new Result().ok(durations);
        } catch (Exception e) {
            return new Result().error("查询失败");
        }
    }
    @ApiOperation(value = "修改时长接口")
    @PutMapping("/duration/update")
    public Result updateTime(Integer redemptionDuration){
        try {
            this.durationService.updateTime(redemptionDuration);
            return new Result().ok();
        } catch (Exception e) {
            return new Result().error("修改失败");
        }
    }
}
